<?php
session_start();
$error = $_SESSION['login_error'] ?? '';
unset($_SESSION['login_error']); // 清除已显示的错误
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Blog 系统</title>
    <link rel="stylesheet" href="CSS/blog_login.css">
    <link rel="stylesheet" href="CSS/index.css">

</head>
<body style="background-image: url('image/bg.png');background-size: cover; background-repeat: no-repeat; background-position: center;">
    <!-- 容器 -->
    <div class="container">

        <!-- 顶部导航栏 -->
        <div class="header">
            <div class="logo">
                <img src="image/log.png" alt="Logo" style="height: 25px;">
                <span style="margin-left: 20px;font-size: 25px;">我的博客</span>
            </div>
            <div >
                <a style="font-size: 15px;" href="#">主页</a>
            </div>
        </div>
        <!-- 顶部导航栏结束 -->
        <div class="parent">
            <div class="child">
                <div class="heade">
                    <span class="blog">Blog</span>
                    <!-- <span class="subtitle">xiaohuai blog</span> -->
                </div>
                <form action="blog_logold.php" method="post">
                <p class="message">xiaohuai的博客 </p>
                    <div class="input-group">
                        <label for="username">学号:</label> 
                        <input id="username"type="text" name="username" placeholder="用户名"><p></p>
                    </div>
                    <div class="input-group">
                        <label for="password">密码:</label>   
                        <input type="password" name="password" placeholder="密码"><p></p>
                        <div class="forgot">
                            <a rel="noopener noreferrer" href="#" >Forgot Password ?</a>
                        </div>
                    </div>
                    <p><?php if (!empty($error)): ?>
                        <div class="error_msg" id="login_errorMsg"><?= $error ?></div>
                        <script src='script/autoHide.js'></script>
                        <script> initAutoHide({ elementId: 'login_errorMsg',delay: 3000 }); </script>
                    <?php endif; ?>
                    </p>
                    <button  class="sign" type="submit" name="login">登录</button>
                    <p class="signup">Don't have an account?
                    <a type="button" name="register" value="register" rel="noopener noreferrer" onclick="window.location.href='register.php'" class="cta">
                        <span>Sign up</span>
                        <svg width="5px" height="7px" viewBox="0 0 13 10">
                            <path d="M1,5 L11,5"></path>
                            <polyline points="8 1 12 5 8 9"></polyline>
                        </svg>
                    </a>
                    </p>
                </form>
            </div>
        </div>
    </div>
    <script src="script/autoHide.js"></script> 
</body>
</html>